package com.mark.web.data.entity.vo;

import com.mark.web.data.entity.po.Product;
import com.mark.common.utils.DateTimeUtil;
import com.mark.common.utils.PropertiesUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * @Description: 商品详细信息VO封装
 * @Author: Mark
 * @CreateDate: 2018/3/26.
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ProductDetailVo {
    private Integer id;
    private Integer categoryId;
    private Integer ownerId;
    private String ownerName;
    private String ownerImage;
    private String productName;
    private String productSubtitle;
    private String productDesc;
    private BigDecimal normalPrice;
    private BigDecimal promotionPrice;
    private Integer productStock;
    private Integer enableStatus;
    private String enableStatusDes;     //商品状态描述
    private String mainImgAddr;
    private String subImgsAddr;
    private Integer priority;
    private String imageHost;
    private Integer parentCategoryId;
    private String createTime;
    private String lastEditTime;


    private String assembleStatus(Integer enableStatus) {//组装商品的状态
        switch (enableStatus){
            case -1 : return "已下架";
            case 0 : return "不合格" ;
            case 1 : return "待审核";
            case 2 : return "出售中";
            default: return "不明确";
        }
    }

    @Override
    public String toString() {
        return "ProductDetailVo{" +
                "id=" + id +
                ", categoryId=" + categoryId +
                ", productName='" + productName + '\'' +
                ", productSubtitle='" + productSubtitle + '\'' +
                ", productDesc='" + productDesc + '\'' +
                ", normalPrice=" + normalPrice +
                ", promotionPrice=" + promotionPrice +
                ", productStock=" + productStock +
                ", enableStatus=" + enableStatus +
                ", mainImgAddr='" + mainImgAddr + '\'' +
                ", subImgsAddr='" + subImgsAddr + '\'' +
                ", createTime='" + createTime + '\'' +
                ", lastEditTime='" + lastEditTime + '\'' +
                ", priority=" + priority +
                ", imageHost='" + imageHost + '\'' +
                ", parentCategoryId=" + parentCategoryId +
                '}';
    }


    public ProductDetailVo assembleProductDetailVo(Product product) {
        ProductDetailVo productDetailVo = new ProductDetailVo();
        productDetailVo.setId(product.getId());
        productDetailVo.setOwnerId(product.getOwnerId());
        productDetailVo.setCategoryId(product.getCategoryId());
        productDetailVo.setProductName(product.getProductName());
        productDetailVo.setProductSubtitle(product.getProductSubtitle());
        productDetailVo.setProductDesc(product.getProductDesc());
        productDetailVo.setNormalPrice(product.getNormalPrice());
        productDetailVo.setPromotionPrice(product.getPromotionPrice());
        productDetailVo.setEnableStatus(product.getEnableStatus());
        productDetailVo.setProductStock(product.getProductStock());
        productDetailVo.setMainImgAddr(product.getMainImgAddr());
        productDetailVo.setSubImgsAddr(product.getSubImgsAddr());
        productDetailVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix",PropertiesUtil.FTP_SERVER_HTTP_PREFIX));
        productDetailVo.setCreateTime(DateTimeUtil.dateToStr2(product.getCreateTime()));
        productDetailVo.setLastEditTime(DateTimeUtil.dateToStr(product.getLastEditTime()));
        return productDetailVo;
    }



}
